cd "/Users/jieluyao/Dropbox/DACA/Data and Models/Data"

*version 14.2
		
set more off
  quietly log
  local logon = r(status)
  if "`logon'" == "on" {
	log close
	}
log using daca_04112023_jielu.log, text replace


* Load the data
use  daca_feb2021.dta, clear

* Label variables
label var external_care "Public Officials Don't Care"
label var external_say "People Like Me Have No Say"
label var external_comb "Combined External Efficacy Scale"
label var internal_complic "Politics is complicated"
label var internal_understand "I Have a Good Understanding"
label var part_scale  "Participation Index"
label var part_binary "Participation Binary"
label var external_care "Public Officials Don't Care"
label var external_say "People Like Me Have No Say"
label var daca "DACA"
label var deport_rate_cl3 "Noncriminal Deportation Rate"
label var deport_rate "Deportation Rate"
label var age "Age"
label var age_square "Age Squared"
label var female "Female"
label var educ "Education"
label var dem_7 "Democrat"
label var ind_7 "Independent"
label var child "Has Child"
label var fulltime "Employed Full Time"
label var married "Married"
label var border_county "Border County"
label var non_citizen "Noncitizen"
label var span_pref "Survey in Spanish" 
label var pctfb "% Foreign-born in County"

label values external_say LABAN
label values internal_complic LABAN

* Table 1 Descriptive statistics
est clear 

eststo tab1: quietly estpost summarize external_care external_say ///
	internal_complic internal_understand part_scale part_binary ///
	daca deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1
	
esttab tab1 using daca_tab1.tex, ///
	cells("count(fmt(a2)) mean(fmt(1)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") label ///
	noobs nomtitle nonumber 
	
* Table 2 Political efficacy - external
est clear 

eststo: quietly ologit external_care i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
eststo: quietly ologit external_care i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

eststo: quietly ologit external_say i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly ologit external_say i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	

esttab using daca_tab2.tex, se(3) b(3) label star(+ 0.10 * 0.05) nobaselevels interaction(" X ") nogaps replace booktabs


* Table 3 Political efficacy - internal
est clear 

eststo: quietly ologit internal_complic i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
eststo: quietly ologit internal_complic i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

eststo: quietly ologit internal_understand i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly ologit internal_understand i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	

esttab using daca_tab3.tex, se(3) b(3) label star(+ 0.10 * 0.05) nobaselevels interaction(" X ") nogaps replace booktabs

* Table 4 Political Participation
est clear 

eststo: quietly regress part_scale i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
eststo: quietly regress part_scale i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

eststo: quietly logit part_binary i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly logit part_binary i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	

esttab using daca_ta4.tex, se(3) b(3) label star(+ 0.10 * 0.05) nobaselevels interaction(" X ") nogaps replace booktabs

* Figure 2
ologit external_care i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
margins, dydx(daca) atmeans	

margins, dydx(daca) at(deport_rate_cl3=(0(1)31)) predict(outcome(1)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("Public Officials Don't Care") ///
	ytitle("Effects on Pr(External_Care = Agree Strongly)") ///
	saving(external_care, replace)

ologit external_say i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

margins daca, at (deport_rate_cl3=(1,31))

margins, dydx(daca) at(deport_rate_cl3=(0(1)31)) predict(outcome(1)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("People Like Me Have No Say") ///
	ytitle("Effects on Pr(External_Care = Agree Strongly)") ///
	saving(external_say, replace)
	
graph combine external_care.gph external_say.gph, ycommon ///
	graphregion(fcolor(white)) ///
	saving(external, replace)
	
graph export external.png, replace




//title("Figure 3: Conditional Marginal Effects of DACA with 95% CIs") ///

* Figure (not included in the paper)

ologit internal_complic i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

margins, dydx(daca) atmeans	
margins, dydx(deport_rate_cl3) at(daca=(0(1)1)) atmeans
	
	
margins, dydx(daca) at(deport_rate_cl3=(0(1)31)) predict(outcome(1)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("Politics is complicated") ///
	ytitle("Effects on Pr(Internal_Care = Agree Strongly)") ///
	saving(internal_complic, replace)

ologit internal_understand i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	

margins, dydx(daca) atmeans	
margins, dydx(deport_rate_cl3) at(daca=(0(1)1)) atmeans	

margins, dydx(daca) at(deport_rate_cl3=(0(1)31)) predict(outcome(1)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("I Have a Good Understanding") ///
	ytitle("Effects on Pr(Internal_Care = Agree Strongly)") ///
	saving(internal_understanding, replace)	
	
	
* Figure 4
regress part_scale i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

margins, dydx(daca) at(deport_rate_cl3=(0(1)31)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("Participation Index") ///
	ytitle("Effects on the Number of Participatory Acts") ///
	saving(part_index, replace)
	
logit part_binary i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
margins, dydx(daca) at(deport_rate_cl3=(0(1)31)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("Participation Binary") ///
	ytitle("Effects on Pr(Participation)") ///
	saving(part_binary, replace)	

graph combine part_index.gph part_binary.gph, ///
	graphregion(fcolor(white)) ///
	saving(participation, replace)
	
graph export participation.png, replace


* Figures in Appendix
* Histograms of external efficacy
hist external_care, percent discrete xla(1/5, valuelabel noticks) start(0.5) width(1) ///
	title ("Public Officials Don't Care") ///
	xtitle ("") xlabel(,angle(45)) ///
	scheme(s1mono) ///
	saving(hist_external_care, replace)

hist external_say, percent discrete xla(1/5, valuelabel noticks) start(0.5) width(1) ///
	title ("People Like Me Have No Say") ///
	xtitle ("") xlabel(,angle(45)) ///
	scheme(s1mono) ///
	saving(hist_external_say, replace)

graph combine hist_external_care.gph hist_external_say.gph, ///
	graphregion(fcolor(white)) ///
	saving(hist_external, replace)
	
graph export hist_external.png, replace

* Histograms of internal efficacy
hist internal_complic, percent discrete xla(1/5, valuelabel noticks) start(0.5) width(1) ///
	title ("Politics is complicated") ///
	xtitle ("") xlabel(,angle(45)) ///
	scheme(s1mono) ///
	saving(hist_internal_complic, replace)

hist internal_understand, percent discrete xla(1/5, valuelabel noticks) start(0.5) width(1) ///
	title ("I Have a Good Understanding") ///
	xtitle ("") xlabel(,angle(45)) ///
	scheme(s1mono) ///
	saving(hist_internal_understand, replace)

graph combine hist_internal_complic.gph hist_internal_understand.gph, ///
	graphregion(fcolor(white)) ///
	saving(hist_internal, replace)
	
graph export hist_internal.png, replace

* Histograms of Participation
hist part_scale, percent discrete xla(0/8, valuelabel noticks) start(-0.5) width(1) ///
	title ("Participation Index") ///
	xtitle ("")  ///
	scheme(s1mono) ///
	saving(hist_part_scale, replace)

hist part_binary, percent discrete xla(0/1, valuelabel noticks) start(0)  width(1) ///
	title ("Participation Binary") ///
	xtitle ("")  ///
	scheme(s1mono) ///
	saving(hist_part_binary, replace)
	
graph combine hist_part_scale.gph hist_part_binary.gph, ///
	graphregion(fcolor(white)) ///
	saving(hist_part, replace)
	
graph export hist_part.png, replace

* Figure A4 
ologit external_care i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
margins, dydx(daca) atmeans	

margins, dydx(daca) at(deport_rate=(0(1)31)) predict(outcome(1)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("Public Officials Don't Care") ///
	ytitle("Effects on Pr(External_Care = Agree Strongly)") ///
	saving(external_care, replace)

ologit external_say i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

margins, dydx(daca) at(deport_rate=(0(1)31)) predict(outcome(1)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("People Like Me Have No Say") ///
	ytitle("Effects on Pr(External_Care = Agree Strongly)") ///
	saving(external_say, replace)
	
graph combine external_care.gph external_say.gph, ycommon ///
	graphregion(fcolor(white)) ///
	saving(external, replace)
	
graph export external_a3.png, replace

*Figure A5
regress part_scale i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

margins, dydx(daca) at(deport_rate=(0(1)31)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("Participation Index") ///
	ytitle("Effects on the Number of Participatory Acts") ///
	saving(part_index, replace)
	
logit part_binary i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
margins, dydx(daca) at(deport_rate=(0(1)31)) atmeans
marginsplot,scheme(s1mono) recast(line) recastci(rarea) ciopt(color(%20) lcolor(%0)) ///
	yline(0, lpattern(dash)) ///
	title ("Participation Binary") ///
	ytitle("Effects on Pr(Participation)") ///
	saving(part_binary, replace)	

graph combine part_index.gph part_binary.gph, ///
	graphregion(fcolor(white)) ///
	saving(participation, replace)
	
graph export participation_A5.png, replace


* Tables in Appendix

* Table A1-external
est clear 

eststo: quietly regress external_comb i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
eststo: quietly ologit external_care i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly ologit external_say i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	

esttab using daca_appendix_external.tex, se(3) b(3) label star(+ 0.10 * 0.05) nobaselevels interaction(" X ") nogaps replace booktabs


* Table A2-internal
est clear 

eststo: quietly regress external_comb i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
eststo: quietly ologit external_care i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly ologit external_say i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	

esttab using daca_appendix_external.tex, se(3) b(3) label star(+ 0.10 * 0.05) nobaselevels interaction(" X ") nogaps replace booktabs

******************************************
* Cronbach's alpha for participation index
******************************************

alpha attendprotest attendmtg petition onlinepetition part_workothers part_contact attendmtg2 part_volunteer, std


alpha attendprotest attendmtg petition onlinepetition part_workothers part_contact attendmtg2 part_volunteer, std item

***********************************
* Goodness of fit - Discrete models
***********************************
* % Correctly predicted
* Table 2 (1)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit external_care i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

tab external_care
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}
tab2 external_care vpred

dis (52+199+11+5)/878
dis (52/227)+(199/359)+(11/200)+(5/20)

* Table 2 (2)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit external_care i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 external_care vpred
dis (55+197+7+5)/878
dis (55/227)+(197/359)+(7/200)+(5/20)

* Table 2 (3)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit external_say i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 external_say vpred
dis (73+79+45+4+8)/878
dis (73/207)+(79/285)+(45/214)+(4/126)+(8/46)

* Table 2 (4)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit external_say i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 external_say vpred
dis (66+77+43+3+8)/878
dis (66/207)+(77/285)+(43/214)+(3/126)+(8/46)

* Table 3 (1)
	
drop p1 p2 p3 p4 p5 maxpred vpred

tab internal_complic

ologit internal_complic i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 internal_complic vpred
dis (3+218+12+7+18)/878
dis (3/147)+(218/338)+(12/213)+(7/122)+(18/59)


* Table 3 (2)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit internal_complic i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 internal_complic vpred
dis (4+213+11+7+18)/879
dis (4/147)+(213/338)+(11/213)+(7/122)+(18/59)

* Table 3 (3)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit internal_understand i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 internal_understand  vpred
dis (83+127+75)/878
dis (83/236)+(127/339)+(75/188)

* Table 3 (4)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit internal_understand i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 internal_understand  vpred
dis (1+83+134+76)/878
dis (1/92)+(83/236)+(134/339)+(76/188)

* Table 4 (3)
drop p vpred

logit part_binary i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

*The following command does not allow weights
*estat classification

predict p
gen vpred = .
replace vpred = 1 if p >= 0.5
replace vpred = 0 if p < 0.5

tab2 part_binary  vpred

dis (183+1059)/1924
dis (183/733) + (1059/1191)

* Table 4 (3)
drop p vpred

logit part_binary i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

predict p
gen vpred = .
replace vpred = 1 if p >= 0.5
replace vpred = 0 if p < 0.5

tab2 part_binary vpred

dis (180+1049)/1924
dis (180/733) + (1049/1191)

***************************************************
* Goodness of fit for regression models (R-squared)
***************************************************

regress part_scale i.daca c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
regress part_scale i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
regress external_comb i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
regress internal_comb i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
	
*********************************************
* Robust check - all types of offenses
*********************************************	


* Table A3 Political efficacy - external
est clear 

eststo: quietly ologit external_care i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
eststo: quietly ologit external_care i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

eststo: quietly ologit external_say i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly ologit external_say i.daca##c.deport_rate ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	

esttab using daca_a3.tex, se(3) b(3) label star(+ 0.10 * 0.05) nobaselevels interaction(" X ") nogaps replace booktabs


* Table A4 Political efficacy - internal
est clear 

eststo: quietly ologit internal_complic i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
eststo: quietly ologit internal_complic i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

eststo: quietly ologit internal_understand i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly ologit internal_understand i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	

esttab using daca_a4.tex, se(3) b(3) label star(+ 0.10 * 0.05) nobaselevels interaction(" X ") nogaps replace booktabs

* Table A5 Political Participation
est clear 

eststo: quietly regress part_scale i.daca c.deport_rate ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
eststo: quietly regress part_scale i.daca##c.deport_rate ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

eststo: quietly logit part_binary i.daca c.deport_rate ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly logit part_binary i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	

esttab using daca_a5.tex, se(3) b(3) label star(+ 0.10 * 0.05) nobaselevels interaction(" X ") nogaps replace booktabs


* Goodness of fit - Discrete models 

* % Correctly predicted
* Table A3 (1)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit external_care i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

tab external_care
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}
tab2 external_care vpred

dis (54+203+8+5)/878
dis (54/227)+(203/359)+(8/200)+(5/20)

* Table A3 (2)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit external_care i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 external_care vpred
dis (56+200+9+5)/878
dis (56/227)+(200/359)+(9/200)+(5/20)

* Table A3 (3)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit external_say i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 external_say vpred
dis (75+78+46+1+8)/878
dis (75/207)+(78/285)+(46/214)+(1/126)+(8/46)

* Table A3 (4)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit external_say i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 external_say vpred
dis (65+75+43+4+8)/878
dis (65/207)+(75/285)+(43/214)+(4/126)+(8/46)

* Table A4 (1)
	
drop p1 p2 p3 p4 p5 maxpred vpred

tab internal_complic

ologit internal_complic i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 internal_complic vpred
dis (6+217+10+8+17)/878
dis (6/147)+(217/338)+(10/213)+(8/122)+(17/59)


* Table A4 (2)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit internal_complic i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 internal_complic vpred
dis (6+213+13+9+17)/879
dis (6/147)+(213/338)+(13/213)+(9/122)+(17/59)

* Table A4 (3)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit internal_understand i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 internal_understand  vpred
dis (1+77+136+77)/878
dis (1/92)+(77/236)+(136/339)+(77/188)

* Table 3 (4)
drop p1 p2 p3 p4 p5 maxpred vpred

ologit internal_understand i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

predict p1 p2 p3 p4 p5
egen maxpred = rowmax(p1-p5)
gen vpred = .
forval i = 1/5 {
replace vpred = `i' if p`i' == maxpred
}

tab2 internal_understand  vpred
dis (1+80+134+77)/878
dis (1/92)+(80/236)+(134/339)+(77/188)

* Table A5 (3)
drop p vpred

logit part_binary i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

*The following command does not allow weights
*estat classification

predict p
gen vpred = .
replace vpred = 1 if p >= 0.5
replace vpred = 0 if p < 0.5

tab2 part_binary  vpred

dis (183+1054)/1924
dis (183/733) + (1054/1191)

* Table 4 (3)
drop p vpred

logit part_binary i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

predict p
gen vpred = .
replace vpred = 1 if p >= 0.5
replace vpred = 0 if p < 0.5

tab2 part_binary vpred

dis (182+1049)/1924
dis (182/733) + (1049/1191)

***************************************************
* Goodness of fit for regression models (R-squared)
***************************************************

regress part_scale i.daca c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
regress part_scale i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
regress external_comb i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
regress internal_comb i.daca##c.deport_rate  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
***************************************************
* Footnote 5: Robust checks on individual participation behaviours
***************************************************
#attendprotest+attendmtg+petition+onlinepetition+part_workothers+part_contact+attendmtg2+part_volunteer
est clear 

eststo: quietly 
logit attendprotest i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
		
eststo: quietly 
logit  attendmtg i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

eststo: quietly logit petition i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly logit onlinepetition i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	
	
eststo: quietly 
logit part_workothers i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	
	
eststo: quietly logit part_contact i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)	
	
eststo: quietly logit attendmtg2 i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)
	
eststo: quietly 
logit part_volunteer i.daca##c.deport_rate_cl3  ///
	age age_square female educ dem_7 ind_7 child fulltime married ///
	border_county non_citizen span_pref pctfb if foreign_born==1 ///
	[pweight=weight], cluster(county)

esttab using daca_f5.tex, se(3) b(3) label star(+ 0.10 * 0.05) nobaselevels interaction(" X ") nogaps replace booktabs






	
	
	
	
	
